
import 'package:flutter/material.dart';

enum LoadingType{
  // 加载中
  loading,
  // 成功
  success,
  // 失败
  fail,

}


class CustomLoadingWidget extends StatefulWidget
{
  /// 构造函数
  const CustomLoadingWidget({
    super.key, 
    required this.msg,
    this.type = LoadingType.loading,
  });

  final String msg;
  final LoadingType type;

  @override
  State<CustomLoadingWidget> createState() => _CustomLoadingWidgetState();
}

class _CustomLoadingWidgetState extends State<CustomLoadingWidget>
{
  @override
  Widget build(BuildContext context)
  {
    if (widget.type == LoadingType.success)
    {
      return const Text('成功');
    }
    else if (widget.type == LoadingType.fail)
    {
      return const Text('失败');
    }

    return const Center(
      child: CircularProgressIndicator(),
    );
  }

}